package com.hzdp.web.captcha;

import java.awt.Color;

import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator;
import com.octo.captcha.component.image.backgroundgenerator.FunkyBackgroundGenerator;
import com.octo.captcha.component.image.color.RandomListColorGenerator;
import com.octo.captcha.component.image.fontgenerator.FontGenerator;
import com.octo.captcha.component.image.fontgenerator.TwistedAndShearedRandomFontGenerator;
import com.octo.captcha.component.image.textpaster.DecoratedRandomTextPaster;
import com.octo.captcha.component.image.wordtoimage.ComposedWordToImage;
import com.octo.captcha.component.image.wordtoimage.WordToImage;
import com.octo.captcha.component.word.wordgenerator.RandomWordGenerator;
import com.octo.captcha.component.word.wordgenerator.WordGenerator;
import com.octo.captcha.engine.image.gimpy.SimpleListImageCaptchaEngine;

public class JcaptchaEngine extends SimpleListImageCaptchaEngine {

	@Override
	protected void buildInitialFactories() {
		// int minWordLength = 4;
		// int maxWordLength = 4;
		// int fontSize = 20;
		// int imageWidth = 100;
		// int imageHeight = 30;
		//
		// WordGenerator wordGenerator = new
		// RandomWordGenerator("0123456789abcdefghijklmnopqrstuvwxyz");
		// TextPaster randPaster = new DecoratedRandomTextPaster(minWordLength,
		// maxWordLength, new RandomListColorGenerator(new Color[] { new
		// Color(23, 170, 27),
		// new Color(220, 34, 11), new Color(23, 67, 172) }), null);
		WordGenerator wordGenerator = new RandomWordGenerator("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
		DecoratedRandomTextPaster textPaster = new DecoratedRandomTextPaster(4, 4, new RandomListColorGenerator(new Color[] { new Color(201, 53, 0),
				new Color(71, 129, 0), new Color(10, 108, 170), new Color(233, 98, 38), new Color(231, 18, 239) }), null);
		// TextPaster textPaster = new RandomTextPaster(new Integer(4), new
		// Integer(4), Color.white);
		BackgroundGenerator bg1 = new FunkyBackgroundGenerator(new Integer(90), new Integer(40), new RandomListColorGenerator(new Color[] { Color.WHITE,
				new Color(244, 248, 254) }));
		BackgroundGenerator bg2 = new FunkyBackgroundGenerator(new Integer(90), new Integer(40), new RandomListColorGenerator(new Color[] { Color.WHITE,
				new Color(235, 248, 255) }));
		BackgroundGenerator bg3 = new FunkyBackgroundGenerator(new Integer(90), new Integer(40), new RandomListColorGenerator(new Color[] { Color.WHITE,
				new Color(247, 253, 236) }));
		JMultiBackgroundGenerator backgroundGenerator = new JMultiBackgroundGenerator(90, 40, new BackgroundGenerator[] { bg1, bg2, bg3 });
		FontGenerator fontGenerator = new TwistedAndShearedRandomFontGenerator(new Integer(16), new Integer(20));
		WordToImage wordToImage = new ComposedWordToImage(fontGenerator, backgroundGenerator, textPaster);
		addFactory(new JGimpyFactory(wordGenerator, wordToImage));
	}

}
